<?php

namespace Modules\File\Models;

use App\Models\BaseModel;
use App\Traits\HasCreateBy;
use App\Traits\HasUnique;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Stancl\Tenancy\Database\Concerns\BelongsToTenant;

class Attachment extends BaseModel
{
    use HasCreateBy;
    use HasUnique;
    use BelongsToTenant;

    protected $table = 'file_attachments';
    protected $fillable = [
        'uuid', 'create_by', 'is_sound', 'is_remote', 'is_approved', 'attachment', 'file_path', 'file_name', 'file_size',
        'file_type', 'ip'
    ];

    public static function boot()
    {
        parent::boot();
        static::creating(function ($model) {
            $model->ip = request()->getClientIp();
        });

    }

}
